package menus.common;

import java.awt.Color;
import java.awt.geom.Point2D;

import components.intertitles.Trial;

import fr.lri.swingstates.canvas.CEllipse;
import fr.lri.swingstates.canvas.Canvas;
import fr.lri.swingstates.gestures.Gesture;

/**
 * Skeleton for marking menus using "tap-and-stroke" selection, as Zone Menus and Polygon Menus
 */
public abstract class TapAndStrokeMenu extends AbstractMenu {

	/**
	 * Radius of the ellipse corresponding to the tap
	 */
	protected int tapRadius = 20;
	
	/**
	 * Ellipse showed to locate the "tap".
	 */
	protected CEllipse tap;
	
	
	
	// ----------------------------------------------------------------- XXX

	
	
	/**
	 * Default constructor.
	 * @param canvas
	 * @param itemLabels
	 */
	public TapAndStrokeMenu(Canvas canvas, String[][] itemLabels) {
		super(canvas, itemLabels);
		
		tap = createTap();
	}
	
	/**
	 * Desactivated for this kind of menus
	 */
	@Override
	@Deprecated
	public AbstractItem getItem(Gesture gesture) {
		return null;
	}
	
	/**
	 * Creates and returns the "tap" ellipse shape. Neither adds it to the menu nor the canvas.
	 * @return
	 */
	public CEllipse createTap(){
		CEllipse tap = canvas.newEllipse(-tapRadius/2, -tapRadius/2, tapRadius, tapRadius);
		tap.setFilled(true)
			.setOutlined(false)
			.setFillPaint(Color.blue)
			
			.addTag(Trial.UtilTag)
			
			.setReferencePoint(.5, .5)
			.setDrawable(false);
		
		return tap;
	}
	
	/**
	 * @return
	 */
	public CEllipse getTap(){
		return tap;
	}
	
	
	
	// ----------------------------------------------------------------- XXX

	
	
	/**
	 * Creates and returns this menu item shape. Neither adds it to the menu nor the canvas.
	 * For this kind of menus, the location of the tap is alse required.
	 * @param tap
	 * @param draw
	 * @return
	 */
	public abstract AbstractItem getItem(Point2D tap, Gesture draw);
	
}
